//
//  YLMyInfoViewController.m
//  YLFinanceService
//
//  Created by she1323 on 2017/8/29.
//  Copyright © 2017年 she1323. All rights reserved.
//  实名信息

#import "YLMyInfoViewController.h"
#import "YLGlobeHeader.h"
#import "YLMyInfoViewModel.h"
#import "YLRealNameModel.h"
#import "YLSwitchRootController.h"
@interface YLMyInfoViewController ()
@property (weak, nonatomic) IBOutlet UITextField *myNameTextField;
@property (weak, nonatomic) IBOutlet UITextField *idCardTextField;
@property (weak, nonatomic) IBOutlet UITextField *bankCardTextField;

@property (nonatomic, strong) YLMyInfoViewModel *viewModel;
@property (weak, nonatomic) IBOutlet UIButton *sureButton;

@end

@implementation YLMyInfoViewController

- (YLMyInfoViewModel *)viewModel
{

    if (!_viewModel) {
        _viewModel = [[YLMyInfoViewModel alloc] init];
    }
    return _viewModel;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self bindViewModel];
    // Do any additional setup after loading the view from its nib.
}

- (void)bindViewModel
{
    RAC(self.viewModel, bankCardText) = _bankCardTextField.rac_textSignal;
    RAC(self.viewModel, myNameText) = _myNameTextField.rac_textSignal;
    RAC(self.viewModel, idCardText) = _idCardTextField.rac_textSignal;
    RAC(self.sureButton, enabled) = self.viewModel.sureEnableSiganl;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)sure:(UIButton *)sender {
    
    [YLSwitchRootController switchMineOrRealName];
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(myInfoViewControllerSure:realNameModel:)]) {
        YLRealNameModel *model = [[YLRealNameModel alloc] init];
        model.bankCardCode = self.viewModel.bankCardText;
        model.name = self.viewModel.myNameText;
        model.identityId = self.viewModel.idCardText;
        [self.delegate myInfoViewControllerSure:self realNameModel:model];
    }
}



@end
